<template>
  <view>
    <view class="item" v-for="(item, index) in list" :key="index">
      <view class="item-left">
        <view class="item-left-top">{{item.msg}}</view>
        <view class="item-left-bottom">{{item._add_time_str}}</view>
      </view>
      
      <view class="item-right" style="color:green" v-if="item.type==7">-{{item.amount}}</view>
      <view class="item-right" v-else>+{{item.amount}}</view>
    </view>
    <view class="no-data" v-if="list.length == 0">暂无数据</view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        userInfo: {},
        list: [],
        type: 1
      }
    },
    onLoad(options) {
      if (options.type) {
        this.type = parseInt(options.type)
        if (this.type == 1) {
          uni.setNavigationBarTitle({
            title: '我的积分'
          })
        }
        if (this.type == 6) {
          uni.setNavigationBarTitle({
            title: '我的油卡'
          })
        }
      }
    },
    onShow() {
      this.userInfo = vk.getVuex('$user.userInfo')
      this.getList()
    },
    methods: {
      getList() {
        uni.showLoading({
          title: '加载中'
        })
        vk.callFunction({
          url: 'user/kh/messageAlljifen',
          data: {
            user_id: this.userInfo._id,
            type: this.type
          },
          success: (res) => {
            uni.hideLoading()
            this.list = res.rows
          }
        })
      }
    }
  }
</script>

<style lang="scss">
 .no-data {
    width: 100%;
    text-align: center;
    font-family: PingFang SC;
    font-size: 24rpx;
    font-style: normal;
    font-weight: 400;
    margin-top: 100rpx;
  }
  .item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 690rpx;
    height: 80rpx;
    padding: 24rpx 30rpx;
    background-color: #fff;
    border-bottom: 1px solid #d9d9d9;
    &-left {
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      &-top {
        font-family: PingFang SC;
        font-size: 30rpx;
        font-style: normal;
        font-weight: 500;
        color: #525252;
      }
      &-bottom {
        color: #969696;
        font-family: PingFang SC;
        font-size: 22rpx;
        font-style: normal;
        font-weight: 400;
      }
    }
    &-right {
      text-align: right;
      font-family: PingFang SC;
      font-size: 34rpx;
      font-style: normal;
      font-weight: 500;
      color: #ff774d
    }
  }
</style>
